package com.wing.system.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.system.dao.SystemDingTalkInfoDao;

import com.wing.system.model.entity.SystemDingTalkInfo;
import com.wing.system.model.entity.SystemNoteInfo;
import com.wing.system.model.request.SystemDingTalkInfoForm;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


/**
 * 钉钉接口表-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class SystemDingTalkInfoServiceImpl extends ServiceImpl<SystemDingTalkInfoDao, SystemDingTalkInfo> implements SystemDingTalkInfoService {

    @Override
    public int addOrUpdate(SystemDingTalkInfoForm systemDingTalkInfoForm) {
        //校验
        SystemDingTalkInfo systemDingTalkInfo =new SystemDingTalkInfo();
        BeanUtil.copyProperties(systemDingTalkInfoForm, systemDingTalkInfo, true);
        SystemDingTalkInfo systemDingTalkInfo1 = baseMapper.selDingTalkOneById(systemDingTalkInfoForm.getId());
        if(systemDingTalkInfo1!=null){
            systemDingTalkInfo.setId(systemDingTalkInfo1.getId());
            return baseMapper.updateById(systemDingTalkInfo);
        }else{
            return baseMapper.insert(systemDingTalkInfo);
        }

    }

}
